package com.neu.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.neu.model.Item;
import com.neu.service.ItemService;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import java.util.List;

@Path("/todo")
public class TodoController {

    @Inject
    ItemService itemService;

    @GET
    @Path("/list")
    @Produces(MediaType.APPLICATION_JSON)
    public List<Item> list(){
        return itemService.getAllTodos();
    }

    @POST
    @Path("/addTodo")
    public void addItem(Item todo){
        itemService.saveTodo(todo);
    }

    @POST
    @Path("/changeState")
    public void changeState(Item todo){
        itemService.changeState(todo);
    }
}
